<template>
    <div class="app-container">
        <el-card shadow="always">
            <div slot="header" class="clearfix">
                <span> {{$t("tool.nianwen")}}</span>
            </div>
            <el-form ref="setting" :inline="true" label-width="auto"  v-for="(item, index) in settingList" :key="index">
                <el-form-item :label='$t("tool.data") + " " + (index + 1)'>

                </el-form-item>
                <el-form-item :label="$t('lab.temperture')">
                    <el-input v-model="item.temperture" clearable type="number">
                    </el-input>
                </el-form-item>

                <el-form-item :label="$t('lab.naindu')" >
                    <el-input v-model="item.niandu" clearable type="number" >
                    </el-input>
                </el-form-item>
            </el-form>
            <el-button-group>
                <el-button @click="cal">
                    cal
                </el-button>
            </el-button-group>
        </el-card>
        <el-card shadow="always">
            <div slot="header" class="clearfix">
                <span> {{$t("tool.pic")}}</span>
            </div>
            <highcharts :options="chartOptions" ref="chart"></highcharts>
        </el-card>
    </div>
</template>

<script>
    import i18n from "../../i18n";

    export default {
        data() {
            return {
                settingList : [
                    {
                        "temperture":"",
                        "niandu": ""
                    },
                    {
                        "temperture":"",
                        "niandu": ""
                    },
                    {
                        "temperture":"",
                        "niandu": ""
                    },
                    {
                        "temperture":"",
                        "niandu": ""
                    },
                    {
                        "temperture":"",
                        "niandu": ""
                    }
                ],
                chartOptions: {
                    zoomType: 'x',
                    title: {
                        text: this.$i18n.tc("tool.chart.title")
                    },
                    yAxis: {
                        title: {
                            text: this.$i18n.tc("lab.naindu")
                        },
                        // type: 'logarithmic'
                    },
                    xAxis: {
                        title: {
                            text: this.$i18n.tc("lab.temperture")
                        }
                    },
                    credits:{
                        enabled: false
                    },
                    series:  [{
                        name: i18n.t("lab.naindu"),
                        data: []
                    }],
                    tooltip: {
                        shared: true,
                        useHTML: true,
                        headerFormat:"",
                        pointFormatter: function () {
                            return this.x +  '<br/><span style="color: '+ this.series.color + '">\u25CF</span> '+
                                this.series.name + ': <b>'+ this.y +'</b><br/>'
                        }
                    },
                    responsive: {
                        rules: [
                            {
                                condition: {
                                    maxWidth: 500
                                },
                                credits:{
                                    enabled: false // 禁用版权信息
                                }
                            }
                        ]
                    }
                }
            }
        },
        methods:{
            cal() {
                this.chartOptions.series[0].data = [];
                this.chartOptions.series[0].data.push([parseFloat(this.settingList[0].temperture), parseFloat(this.settingList[0].niandu)]);
                this.chartOptions.series[0].data.push([parseFloat(this.settingList[1].temperture), parseFloat(this.settingList[1].niandu)]);
                this.chartOptions.series[0].data.push([parseFloat(this.settingList[2].temperture), parseFloat(this.settingList[2].niandu)]);
                this.chartOptions.series[0].data.push([parseFloat(this.settingList[3].temperture), parseFloat(this.settingList[3].niandu)]);

                let a = 1;
                let b = 1.0 / (parseFloat(this.settingList[0].temperture) + 273);
                let c = parseFloat(this.settingList[0].temperture)  + 273;
                let d = c * c;
                let e =  Math.log(parseFloat(this.settingList[0].niandu));
                let f = 1;
                let g = 1.0 / (parseFloat(this.settingList[1].temperture) + 273);
                let h = parseFloat(this.settingList[1].temperture) + 273;
                let i = h * h;
                let j =  Math.log(parseFloat(this.settingList[1].niandu));
                let k = 1;
                let l = 1.0 / (parseFloat(this.settingList[2].temperture) + 273);
                let m = parseFloat(this.settingList[2].temperture) + 273;
                let n = m * m;
                let o =  Math.log(parseFloat(this.settingList[2].niandu));
                let p = 1;
                let q = 1.0 / (parseFloat(this.settingList[3].temperture )+ 273);
                let r = parseFloat(this.settingList[3].temperture) + 273;
                let s = r * r;
                let t =  Math.log(parseFloat(this.settingList[3].niandu));

                console.info("a is " + a + "; b is " + b + "; c is " + c + "; d is " + d + "; e is " + e
                    + "; f is " + f + "; g is " + g + "; h is " + h + "; i is " + i + "; j is " + j+ "; k is " + k
                    + "; l is " + l + "; m is " + m + "; n is " + n + "; o is " + o + "; p is " + p+ "; q is " + q
                    + "; r is " + r + "; s is " + s + "; t is " + t
                )

                let delta = eval((a*g*m*s)+(a*h*n*q)+(a*i*l*r)-(a*i*m*q)-(a*g*n*r)-(a*h*l*s)-(f*b*m*s)-(f*c*n*q)-(f*d*l*r)+(f*d*m*q)+(f*b*n*r)+(f*c*l*s)+(k*b*h*s)+(k*c*i*q)+(k*d*g*r)-(k*d*h*q)-(k*b*i*r)-(k*c*g*s)-(p*b*h*n)-(p*c*i*l)-(p*d*g*m)+(p*d*h*l)+(p*b*i*m)+(p*c*g*n));
                let wnum = eval((e*g*m*s)+(e*h*n*q)+(e*i*l*r)-(e*i*m*q)-(e*g*n*r)-(e*h*l*s)-(j*b*m*s)-(j*c*n*q)-(j*d*l*r)+(j*d*m*q)+(j*b*n*r)+(j*c*l*s)+(o*b*h*s)+(o*c*i*q)+(o*d*g*r)-(o*d*h*q)-(o*b*i*r)-(o*c*g*s)-(t*b*h*n)-(t*c*i*l)-(t*d*g*m)+(t*d*h*l)+(t*b*i*m)+(t*c*g*n));
                let wans = (wnum/delta);

                let xnum = eval((a*j*m*s)+(a*h*n*t)+(a*i*o*r)-(a*i*m*t)-(a*j*n*r)-(a*h*o*s)-(f*e*m*s)-(f*c*n*t)-(f*d*o*r)+(f*d*m*t)+(f*e*n*r)+
                        (f*c*o*s)+(k*e*h*s)+(k*c*i*t)+(k*d*j*r)-(k*d*h*t)-(k*e*i*r)-
                        (k*c*j*s)-(p*e*h*n)-(p*c*i*o)-(p*d*j*m)+(p*d*h*o)+(p*e*i*m)+
                        (p*c*j*n));

                let xans = (xnum/delta);

                let ynum = eval((a*g*o*s)+(a*j*n*q)+(a*i*l*t)-(a*i*o*q)-(a*g*n*t)-(a*j*l*s)-(f*b*o*s)-(f*e*n*q)-(f*d*l*t)+(f*d*o*q)+(f*b*n*t)+
                    (f*e*l*s)+(k*b*j*s)+(k*e*i*q)+(k*d*g*t)-(k*d*j*q)-(k*b*i*t)-
                    (k*e*g*s)-(p*b*j*n)-(p*e*i*l)-(p*d*g*o)+(p*d*j*l)+(p*b*i*o)+
                    (p*e*g*n));

                let yans = (ynum/delta);

                let znum= eval((a*g*m*t)+(a*h*o*q)+(a*j*l*r)-(a*j*m*q)-(a*g*o*r)-(a*h*l*t)-(f*b*m*t)-(f*c*o*q)-(f*e*l*r)+(f*e*m*q)+(f*b*o*r)+
                        (f*c*l*t)+(k*b*h*t)+(k*c*j*q)+(k*e*g*r)-(k*e*h*q)-(k*b*j*r)-
                        (k*c*g*t)-(p*b*h*o)-(p*c*j*l)-(p*e*g*m)+(p*e*h*l)+(p*b*j*m)+
                        (p*c*g*o));

                let zans = (znum/delta);
                console.info(wans);
                console.info(xans);
                console.info(yans);
                console.info(zans);

                this.settingList[4].niandu = Math.exp(wans + xans / (parseFloat(this.settingList[4].temperture) + 273) + yans * (parseFloat(this.settingList[4].temperture) + 273) + zans * (parseFloat(this.settingList[4].temperture) + 273) * (parseFloat(this.settingList[4].temperture) + 273))

            }
        }
    }
</script>

<style scoped>

</style>
